﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MainFrame.Plugs
{
    public static class ProxyHelper
    {
        private static Dictionary<string, Action<string, string>> dict = new Dictionary<string, Action<string, string>>();

        public static void RegisterHttpApiCallBack(string url,Action<string,string> fnHandler)
        {
            dict[url] = fnHandler;
        }

        public static bool Exists(string url)
        {
            return dict.ContainsKey(url);
        }

        public static void HandHttpResponse(string url,string requestBody,string responseBody)
        {
            if (!dict.ContainsKey(url))
                return;
            dict[url].Invoke(requestBody, responseBody);
        }
    }
}
